<template>
  <div>
    <div>
      <el-button type="primary" @click="dialogFormVisible = true"
        >+新加角色</el-button
      >
    </div>
    <div>
      <el-dialog title="新增" :visible.sync="dialogFormVisible">
        <el-form :model="form">
          <el-form-item label="角色名称" :label-width="formLabelWidth">
            <el-input v-model="rname" autocomplete="off"></el-input>
          </el-form-item>

          <el-form-item label="角色编码" :label-width="formLabelWidth">
            <el-input v-model="pip" autocomplete="off"></el-input>
          </el-form-item>

          <el-form-item label="描述">
            <el-input type="textarea" v-model="desc"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">关闭</el-button>
          <el-button type="primary" @click="tian">确定</el-button>
        </div>
      </el-dialog>
    </div>

    <div>
      <template width="100%">
        <el-table :data="like" >
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column prop="id" label="序号" width="180" align="center">
          </el-table-column>
          <el-table-column prop="rname" label="角色名称" width="180" align="center">
          </el-table-column>
          <el-table-column prop="pip" label="角色编号" width="180" align="center">
          </el-table-column>
           <el-table-column prop="create_time" label="时间" width="180" align="center">
          </el-table-column>
           <el-table-column width="390" align="center"> <el-button>编辑</el-button></el-table-column >
        </el-table>
      </template>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "",
  data() {
    return {
      dialogTableVisible: false,
      dialogFormVisible: false,
      rname: "",
      pip: "",
      like: [],
      desc: "",
    };
  },
  props: {},

  components: {},

  created() {},

  mounted() {
    axios
      .get("http://127.0.0.1:8010/api/mall/v1/admin/role/add/list")
      .then((result) => {
        this.like = result.data.data.items;
        console.log(result);
      })
      .catch((err) => {
        console.log(err);
      });
  },


  methods: {
    tian() {
      axios
        .post("http://127.0.0.1:8010/api/mall/v1/admin/role/add/role", {
          rname: this.rname,
          pip: this.pip,
        })
        .then((result) => {
          this.$message({
            message: "添加成功",
            type: "success",
          });
          this.dialogFormVisible = false;
        })
        .catch((err) => {
          console.log("添加失败", err);
        });
    },
  },

  computed: {},

  watch: {},

  directives: {},

  filters: {},
};
</script>

<style scoped>
* {
  margin: 0;
}
</style>
